package org.paris8.trombino.web.controller;

import java.util.ArrayList;
import java.util.List;

import org.paris8.trombino.model.Album;
import org.paris8.trombino.model.Photo;
import org.paris8.trombino.service.PhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class PhotoController {
	@Autowired
	@Qualifier("PhotoService")
	private PhotoService photoService;

	@RequestMapping(value = "index")
	public void index_jsp(Model model) {
		model.addAttribute("title", "Xinxin 欣欣你好");
		System.out.println("index.jsp");
	}
	
	@RequestMapping(value = "photo/list", method = {RequestMethod.GET})
	public void photo_list(Model model) {
		List<Album> albumList = new ArrayList<Album>();
		albumList = photoService.GetAlbumList();
		
		model.addAttribute("albumList", albumList);
	}
	
	@RequestMapping(value = "photo/detail/{photoId}", method = {RequestMethod.GET})
	public String photo_detail(Model model, @PathVariable String photoId) {
		Photo photo = photoService.GetPhotoById(photoId);
		model.addAttribute("photo", photo);
		
		return "photo/detail";
	}

	
	@RequestMapping(value = "photo/add", method = {RequestMethod.GET})
	public void photo_add(Model model) {
	

	}
}
